package com.geek.health.config;

import com.geek.health.job.CleanImgJob;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class QuartzConfig {

    //任务明细：定时删除垃圾图片信息
    @Bean
    public JobDetail jobDetail() {
        return JobBuilder.newJob(CleanImgJob.class).storeDurably().build();
    }


    //触发器
    @Bean
    public Trigger trigger() {
        //任务调度器
        //每天凌晨两点     0 0 2 * * ? *
        //每隔20s执行任务  0/20 0 * * * ? *
        CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule("0/20 * * * * ?");
        //触发器
        return TriggerBuilder.newTrigger().forJob(jobDetail()).withSchedule(scheduleBuilder).build();
    }

}
